package cn.dlc.com.config;

import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.caucho.hessian.server.HessianServlet;

import cn.dlc.com.service.UserService;
import cn.dlc.com.service.impl.UserServiceImpl;

@Configuration
public class AppConfig{

	/**
	 * 注册这个servlet，注意如果是在web-xml里面配置servlet的话参数是不一样的
	 * @return
	 */
	@SuppressWarnings({ "rawtypes", "unchecked" })
	@Bean
	public ServletRegistrationBean hessianServlet() {
		// 创建一个servlet对象
		HessianServlet hessianServlet = new HessianServlet();
		
		UserService userService = new UserServiceImpl();
		hessianServlet.setService(userService);
		
		return new ServletRegistrationBean(hessianServlet, "/api/service");  
	}
}
